package com.example.carrierapp.ui.person.notice.detail;

import android.os.Bundle;
import android.text.Html;
import android.widget.TextView;

import com.example.carrierapp.base.MVPBaseActivity;
import com.example.carrierapp.bean.home.NoticeDetailBean;
import com.example.carrierapp.config.ConstValue;
import com.example.carrierapp.util.DateUtils;
import com.example.lb.fingerdemo.R;

import butterknife.BindView;
import butterknife.ButterKnife;

public class NoticeDetailActivity extends MVPBaseActivity<NoticeDetailContract.View, NoticeDetailPresenter> implements NoticeDetailContract.View {
    @BindView(R.id.tv_detail_title)
    TextView mTvTitle;
    @BindView(R.id.tv_detail_time)
    TextView mTvTime;
    @BindView(R.id.notice_info_content)
    TextView mTvContent;
    private int mId;

    @Override
    protected NoticeDetailPresenter createPresenter() {
        return new NoticeDetailPresenter(this);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mId = getIntent().getIntExtra(ConstValue.ID, 0);
        showProgress();
        mPresenter.attachView(this);
        mPresenter.getNoticeDetail(mId);
    }

    @Override
    public void initView() {
        super.initView();
        ButterKnife.bind(this);

    }

    @Override
    public int getContentView() {
        return R.layout.activity_notice_detail;
    }

    @Override
    public String getTitleString() {
        return "通知详情";
    }

    @Override
    public void getNoticeDetailSuccess(NoticeDetailBean bean) {
        dismissProgress();
        mTvTitle.setText(bean.title);
        mTvTime.setText(DateUtils.getTimeInterval(bean.creationTime));
        mTvContent.setText(Html.fromHtml(bean.content));
    }

    @Override
    public void getNoticeDetailFailed(String msg) {
        dismissProgress();
    }
}
